import http from "./http"


// 主页
// 获取新闻分类
export function NewsClassification(pageNum,pageSize) {
    let urlParams = new URLSearchParams()
    urlParams.append("pageNum",pageNum);
    urlParams.append("pageSize",pageSize);
    return http.post(`/cms_api/api/cms/category/open/list`,urlParams)
}

//获取新闻轮播图
export function NewsClassslide(pageNum,pageSize) {
    let urlParams = new URLSearchParams()
    urlParams.append("pageNum",pageNum);
    urlParams.append("pageSize",pageSize);
    return http.post(`/cms_api/api/cms/article/open/banner/list`,urlParams)
}

// 获取新闻列表id
export function Newslist(pageNum,pageSize,categoryId) {
    let urlParams = new URLSearchParams()
    urlParams.append("pageNum",pageNum);
    urlParams.append("pageSize",pageSize);
    urlParams.append("categoryId",categoryId);
    return http.post(`/cms_api/api/cms/article/open/list`,urlParams)
}
// 获取新闻列表title
export function NewslistTitle(pageNum,pageSize,title) {
    console.log(title);
    let urlParams = new URLSearchParams()
    urlParams.append("pageNum",pageNum);
    urlParams.append("pageSize",pageSize);
    urlParams.append("title",title);
    return http.post(`/cms_api/api/cms/article/open/list`,urlParams)
}

// 获取热门新闻列表
export function hotNewslist(pageNum,pageSize) {
    let urlParams = new URLSearchParams()
    urlParams.append("pageNum",pageNum);
    urlParams.append("pageSize",pageSize);
    return http.post(`/cms_api/api/cms/article/open/hot/list`,urlParams)
}





// 获取新闻详情
export function NewsInfo(articleId) {
    console.log(articleId)
    return http.get(`/cms_api/api/cms/article/open/detail/${articleId}`)
}

// 增加阅读量
export function read(id) {
    // console.log(articleId)
    return http.get(`/cms_api/api/cms/article/open/add/read-num/${id}`)

}
// /api/cms/article/open/add/read-num/{id}

// 点赞
export function like(articleId) {
    console.log(articleId)
    return http.get(`/cms_api/api/cms/article/add/zan/${articleId}`)

}
// 收藏文章
export function collect(articleId) {
    console.log(articleId)
    return http.get(`/cms_api/api/cms/collect/collect/article/${articleId}`)

}










// 网易云
//网易云音乐
export function music() {
    return http.get("/music-api/artist/list")
}




// 个人中心

//登录
export function loginIn(username,password) {
    let urlParams = new URLSearchParams()
    urlParams.append("username",username)
    urlParams.append("rememberMe",true)
    urlParams.append("password",password)
    return http.post("/cms_api/api/login",urlParams)
}
//注册
export function registered(loginName,code,phonenumber,password,userName) {
    let urlParams = new URLSearchParams()
    urlParams.append("loginName",loginName)
    urlParams.append("code",code)
    urlParams.append("phonenumber",phonenumber)
    urlParams.append("password",password)
    urlParams.append("userName",userName);
    return http.post("/cms_api/api/registry",urlParams)
}
//忘记密码
export function forget(loginName,password,phonenumber,code) {
    let urlParams = new URLSearchParams()
    urlParams.append("loginName",loginName)
    urlParams.append("password",password)
    urlParams.append("phonenumber",phonenumber)
    urlParams.append("code",code)
    return http.post("/cms_api//api/password/forget",urlParams)
}
//手机验证码
export function testing(mobile) {
    return http.get(`/cms_api/api/short-message/vcode/${mobile}`)
}
//查看个人信息
export function checkInfo() {
    return http.get("/cms_api/api/login-user/info")
}
//退出登录
export function logOut() {
    return http.get("/cms_api/api/logout")
}
//收藏列表
export function coll() {
    return http.get("/cms_api/api/cms/article/collect/list")
}
// 修改头像
export function changeAvatar(file) {
    console.log(file)
    let form = new FormData();
    form.append("avatarfile",file);
    return http.post("cms_api/api/system/user/profile/update/avatar/nos",form)

}




// 问答

export function wenda(question) {
    return http.post(`jisu-api/?appkey=yourappkey&question=${question}`)

}



//星座
export function constellation(xingxing){
    return http.get(`/constellation/constellation/getAll?&consName=${xingxing}&type=year&key=f0fc0cd63db7422e8dd74a1b3b4125e5`)
}


//线上新闻地址
export function news() {
    return http.get("/news-api?type=top&page=&page_size=10&is_filter=&key=addaf38a60f8c48d1d87f8dcff9a285e")
}